import numpy
import tensorflow as tf
import tensorflow.keras as keras

print("TensorFlow version:", tf.version)
print("Keras version:", keras.__version__)
print("Numpy version:", numpy.__version__)

# 检查是否有可用的 GPU
gpus = tf.config.list_physical_devices('GPU')
if gpus:
    print("GPU is available")
    # 打印 GPU 设备信息
    for gpu in gpus:
        print("Name:", gpu.name, "Type:", gpu.device_type)
        print("Num GPUs Available: ", len(tf.config.experimental.list_physical_devices('GPU')))
else:
    print("GPU is NOT available")

'''
# 1-安装tensorflow显示GPU不可用
- Keras version: 2.2.4-tf
- Numpy version: 1.21.6
- TensorFlow version: 2.18.0
- GPU is NOT available

# 2-安装tensorflow显示GPU可用
- GPU is available
- Name: /physical_device:GPU:0 Type: GPU
- Num GPUs Available:  1
'''
